package Action;
import hibconfig.HibernateSessionFactory;
import java.util.List;
import org.hibernate.Session;
import entity.Student;



public class LoginAction {
	   private String id;
       private String pwd;   
 	   
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	
	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public String studentlogin(){
		if(id.equals("")){
			return "error";
		}else{	
		Session session=HibernateSessionFactory.getSession();
		String hql="from Student where stuid='"+id+"'";
		List list=session.createQuery(hql).list();
		Student stu=(Student) list.get(0);
		session.close();
		if((stu.getStuid().equals(id))&&(stu.getStupwd().equals(pwd))){
			
			return "success";
		}else{
			return"error";
		 }
		}
	}
	public String teacherlogin(){
		if((id.equals("root"))&&(pwd.equals("root"))){
			return "success";
		}else{
			return"error";
		}
}
	
   }

